package com.studyroom.controller;

import com.studyroom.dto.Result;
import com.studyroom.dto.RoomPageDTO;
import com.studyroom.entity.Room;
import com.studyroom.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/room")
public class RoomController {
    @Autowired
    private RoomService roomService;
    @RequestMapping("/getPageByType")
    public Result getPageByType(@RequestBody RoomPageDTO roomPageDTO){
        return roomService.getPageByType(roomPageDTO);
    }
    @RequestMapping("/getById")
    public Result getById(@RequestParam Long id){
        return roomService.getById(id);
    }
    @PostMapping("/add")
    public Result add(@RequestBody Room room){
        return roomService.add(room);
    }
    @PostMapping("/getByUserId")
    public Result getByUserId(){
        return roomService.getByUserId();
    }
    @PostMapping("/delById")
    public Result delById(@RequestParam Long id){
        return roomService.delById(id);
    }
}
